package com.ysstech.common.enums;

import java.util.Arrays;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 验证码常量类
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum YssCodeEnum implements BaseEnum<Integer> {
    ONE(1, "生成6位纯数字手机验证码"),
    TWO(2, "生成6位包含数字和字母组合验证码"),
    THREE(3, " 生成4位数字和字母组合验证码"),
    FOURE(4, "生成4位纯数字手机验证码"),
    TIMEOUT(120, "验证码过期时间");


    private final Integer code;
    private final String desc;

    public static YssCodeEnum getEnum(Integer code) {
        return Arrays.stream(values()).filter(b -> b.code == code).findFirst().orElse(null);
    }

    public static String getEnumDesc(Integer code) {
        YssCodeEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
